﻿@model IEnumerable<CmsAdminWorkflowApprovedModel>
           
@functions 
{
    string DisplayNullableDates(DateTime? date)
    {
        return date.HasValue ?
            date.Value.ToString("dd/MM/yyyy") :
            string.Empty;
    }
}

@(Html.CmsGrid<CmsAdminWorkflowApprovedModel>(Model, new { @class = "t-grid" }).Wrapper("AprovedItemGrid")
    .Columns(
            columns =>
            {
                columns.HeaderCssClass("t-grid-header").Bound().Width(40).Title("Content title").HtmlAttributes(new { @class = "t-header" });
                columns.Bound().Title("Type").HtmlAttributes(new { @class = "t-header" });
                columns.Bound().Title("Publish date").HtmlAttributes(new { @class = "t-header" });
                columns.Bound().Title("").HtmlAttributes(new { @class = "t-header" });
                columns.Bound().Width(40).Title("").HtmlAttributes(new { @class = "t-header" });
            })
    .Rows(
        rows =>
        {
            rows.Bound().RowItemTemplate(
                @<text>
                <a href="@Url.Action("edit", "cmspage", new { id = item.Id })">@item.Title</a>
                </text>
                );
            rows.Bound().RowItemTemplate(
                @<text>
                <span>@item.EntityType</span>
                </text>
                ).HtmlAttributes(new { @class = "text-center" });
            rows.Bound().RowItemTemplate(
                @<text>
                <span>@DisplayNullableDates(item.PublishedDate)</span>
                </text>
                ).HtmlAttributes(new { @class = "text-center" });           
            rows.Bound().RowItemTemplate(
                @<text>
                <span>@item.Id</span>
                </text>
                );
            rows.Bound().RowItemTemplate(
                @<text>
                <a class="b-icon b-icon_delete" title="Page" href="@Url.Action("delete", "cmspage", new { id = item.Id })">Delete</a>
                </text>
                ).HtmlAttributes(new { @class = "t-last" });
        })
    .Render()
)